<?php
namespace Database;

class CostCategory extends Base
{

    public function __construct()
    {
        $this->setModel(MODEL_COSTCATEGORY);
    }

    public function getIndex($page, $limit, $extension = [])
    {
        return $this->getIndexByOrder($page, $limit, 'dry_data_sort', 'asc');
    }

    public function getParent()
    {
        $sql = $this->getSql();
        $sql->field('*');
        $sql->table($this->getTable());
        $sql->setOrder('dry_data_sort', 'asc');
        $list = $this->fetchAll($sql->get());
        return $list;
    }

    public function getList($data)
    {
        $sql = $this->getSql();
        $sql->field('*');
        $sql->table($this->getTable());
        $sql->where('dry_user', 'in', $data);
        $sql->setOrder('id', 'desc');
        $list = $this->fetchAll($sql->get());
        $count = $this->fetchColumn($sql->getTotalSql());
        return [
            'list' => $list,
            'count' => $count
        ];
    }

}